package com.zhihu.jjn.demoproject.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zhihu.jjn.demoproject.entity.Response;
import com.zhihu.jjn.demoproject.entity.User;
import com.zhihu.jjn.demoproject.service.UserService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Jiang Jining
 * @date 2020/11/1 11:06
 */
@RestController
@CrossOrigin
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping(value = "/api/user/register")
    public Response userRegisterController(@RequestBody User user) throws JsonProcessingException {
        return Response.success(userService.registerUser(user));
    }
}
